package structual_pattern.decorator_pattern;

public class DecoratorPattern {

}
interface Component{
    void operation();
}

class Decorator implements Component {
    public void setComponent(Component component) {
        this.component = component;
    }

    public Decorator(Component component) {

        this.component = component;
    }

    Component component;
    @Override
    public void operation() {
        component.operation();
    }
}
class ConcreteComponent implements Component{
    @Override
    public void operation() {
        System.out.println("concrete");
    }
}
class ConcreteDecoratorA extends Decorator{
    public ConcreteDecoratorA(Component component) {
        super(component);
    }

    @Override
    public void operation() {
        this.addedBehavior();
        super.operation();
    }
    public void addedBehavior(){
        System.out.println("new behaviorA");

    }
}
class ConcreteDecoratorB extends Decorator{
    public ConcreteDecoratorB(Component component) {
        super(component);
    }

    @Override
    public void operation() {
        this.addedBehavior();
        super.operation();
    }
    public void addedBehavior(){
        System.out.println("new behaviorB");

    }
}